﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using TetrisLibrary.Properties;

namespace TetrisLibrary {
    public class MusicController {

        private static MusicController musicController;

        public static MusicController Instance() {
            if (musicController == null)
                musicController = new MusicController();
            return musicController;
        }

        /// <summary>
        /// 音乐播放器
        /// </summary>
        private readonly SoundPlayer soundPlayer = new SoundPlayer(Resources.tetris);

        private MusicController() {
            soundPlayer.Load();
        }

        public void Play() {
            soundPlayer.PlayLooping();
//            if (soundPlayer.IsLoadCompleted) {
//                soundPlayer.PlayLooping();
//            } else {
//                soundPlayer.LoadCompleted += (sender, args) => {
//                    Play();
//                };
//            }
        }

        public void Stop() {
            soundPlayer.Stop();
        }

    }
}
